using System;
using System.Windows.Forms;
using System.Drawing;
using Crownwood.Magic.Controls;
using System.ComponentModel;

namespace Shraga.Client
{
	/// <summary>
	/// Summary description for DragTree.
	/// </summary>
	public class MirroredTree : TreeView
	{
		public delegate void doubleClickNoToggle(object sender, EventArgs e);
		public event doubleClickNoToggle DoubleClickNoToggle;		
    
		public MirroredTree()
			: base()
		{

		}
        
		protected override void WndProc(ref Message m)
		{
			switch(m.Msg)
			{
				//iliminate expand of the tree with double click 
				case (int)Crownwood.Magic.Win32.Msgs.WM_LBUTTONDBLCLK:
					if (DoubleClickNoToggle!=null)
						DoubleClickNoToggle(this,new EventArgs());
					break;
				default:
        			base.WndProc(ref m);
					break;
			}

		}

		#region Mirroring Stuff

		const int WS_EX_LAYOUTRTL = 0x400000;
		private bool _mirrored= false;
		[Description("Change to the right-to-left layout."),DefaultValue(false), 
		Localizable(true),Category("Appearance"),Browsable(true)] 
		public bool Mirrored
		{
			get
			{
				return _mirrored;
			}
			set
			{
				if (_mirrored != value) 
				{
					_mirrored = value;
					base.OnRightToLeftChanged(EventArgs.Empty);
				}
			}
		}
	
		protected override CreateParams CreateParams
		{
			get
			{
				if (_mirrored==true)
				{
					CreateParams CP;
					CP = base.CreateParams;
					CP.ExStyle = CP.ExStyle | WS_EX_LAYOUTRTL ;
					return CP;
				}
				else return base.CreateParams;
			}
		}
		
		#endregion
	}
}